import bisect
from collections import defaultdict

N, D = map(int, input().split())
a = list(map(int, input().split()))
hash_map = defaultdict(list)

for i, v in enumerate(a):
    hash_map[v].append(i)
result = 1
for key, values in hash_map.items():
    cnt = 1 + len(values)
    # 取零个或者取一个的情况可以直接加上
    for i, s in enumerate(values):
        # 使用二分查找寻找小于该元素+D的最小元素
        target_index = bisect.bisect_right(values, s + D) - 1
        cnt += target_index - i
    result = (result * cnt) % int(1e9 + 7)
print(result - 1)
